﻿using Basic.HrOperateLogModular;
using Basic.HrOperateLogModular.ApiRouteFilter;
using Basic.OAGatewayModule.ExtendService;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Interface;

namespace Basic.OAGatewayModule
{
    public class OAGatewayApiModular : BasicApiModular
    {
        public OAGatewayApiModular () : base("OAApi_Gateway")
        {
        }

        protected override void Load ( IHttpGatewayOption option, IModularConfig config )
        {
            option.Option.Option.LoadModular<HrOpLogModular>();
            this.AddFilters<OperateLogFilter>();
            config.ApiRouteFormat = "/oa/{controller}/{name}";
            option.IocBuffer.SetDefLifetimeType(( body ) =>
            {
                if ( body.To.FullName.StartsWith("Basic.OAGatewayModule.Interface.") || body.To.FullName.StartsWith("Basic.OAGatewayModule.ExtendService.Interface.") )
                {
                    body.SetLifetimeType(ClassLifetimeType.SingleInstance);
                }
            });
        }
        protected override void Init ()
        {
            EnumService.Load();
        }
    }
}
